package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    @Select("select * from user where openid=#{openid}")
    User getByUserId(String openid);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into user(id, openid, name, phone, sex, id_number, avatar, create_time) VALUES " +
            "(#{id},#{openid},#{name},#{phone},#{sex},#{idNumber},#{avatar},#{createTime})")
    void insert(User user);

    @Select("select * from sky_take_out.user where user.id=#{userId}")
    User getById(Long userId);
}

